<?php
ob_start();
session_start();
include "inc/conn.php";
$tts = date("YmdHis",time());
function a_array_unique($array_qq) {
	$out_new=array(); //定义变量out为一个数组
	foreach ($array_qq as $key=>$value) //将$array数组按照$key=>$value的样式进行遍历
	{
		if (!in_array($value, $out_new))//如果$value不存在于out数组中，则执行
		{
			$out_new[$key] = $value; //将该value值存入out数组中
		}
	}
	return $out_new; //最后返回数组out
}


if(isset($_POST['submit5'])){
    if($_POST['pwd']==$password){
    	$_SESSION['pwd']=$_POST['pwd'];
    	// echo "<script>window.location='scan.php'</script>";
      header("location:manage.php?v={$tts}");
    } else{echo "<script>alert('密码错误');</script>";}
}

$tj = isset($_GET['tj'])?$_GET['tj']:"";
 if($tj == 'logout'){
     session_start(); //开启session
     session_destroy();  //注销session
     header("location:manage.php?v={$tts}"); //跳转到首页

 }
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link href="http://lib.baomitu.com/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://at.alicdn.com/t/font_374778_ufdzobu4bkh.css">
<link href="inc/css/wap.css?v=<?php echo $tts;?>" rel="stylesheet" type="text/css" />
<title>后台管理</title>
<style>
	body{font-family: 'Microsoft Yahei', Helvetica, 'Hiragino Sans GB', '微软雅黑', Arial, sans-serif;font-size: 1rem;}
	.page-wrap { margin-right: auto; margin-left: auto;padding: 0px 10px 10px 10px; }
	.myform {display: flex; flex-direction: column; margin-top: 58px;}
	.myform input {margin-bottom: 10px; } 
	header { background-color: #2196F3; color: #ffffff;position:fixed;top:0;left:0;width:100%; }
	header .back {position: absolute; left: 10px; top: 0px; }
	header .back .iconfont {color: #ffffff; font-size: 28px; }
	.hd-title {text-align: center; padding: 10px 0; }
	.item-list {font-size: 14px; padding-top: 15px; display: none;}
	.item-list .item { padding: 3px 0px; display:flex;}
	.item-list .item:nth-of-type(2n) { background-color: #f5f5f5;}
	.item-list .item span {flex-basis: 18%;color: #414141; }
	.item-list .item span.c_time {margin-left: auto; flex-grow: 1; text-align: right;color: #009688; }
	
	.toggle-nav {z-index: 1001; top: 0; right: 0; padding: 0px 10px; height: 44px; transition: .3s;}
	.toggle-nav:visited, .toggle-nav:hover{color: #ffffff;transform: rotateZ(180deg);}
	li,ul{margin:0;padding:0;list-style:none;}
	.tabbox{margin-top:94px;}
	.tabbox>ul{position:fixed;top:44px;left:0;display:flex;margin-bottom:10px;width:100%;background-color:#f5f5f5;box-shadow:0 2px 3px 0 #e0e0e0;justify-content:space-between;}
	.tabbox>ul>li{width:50%;height:40px;border-bottom:2px solid transparent;text-align:center;line-height:40px;cursor:pointer;}
	.tabbox>ul>li.active{border-color:#2196F3;}
	.item-list.active{display:block;}
	.more-btn{display: none;}
	.active+.more-btn{display: block;}
	.hidden{display: none;}
	.list-content .more-btn {font-size: 14px; text-align: center; margin-top: 10px; }
	.list-content .more-btn> a {display: block; padding: 8px 0px; background-color: #e8e8e8; }
	.list-content .more-btn>p {padding: 8px 0; background-color: #e8e8e8; }
	@media (min-width: 576px) { 
		html{font-size: 16px;}
	}

	@media (min-width: 768px){
		html{font-size: 17.75px;}
	}
	@media (min-width: 992px){
		html{font-size: 18.75px;height: 100%;}
		body {height: 101%; }
		.page-wrap {width: 980px; }
		.tabbox {
		  margin-top: 0px;
		  padding-top: 108px;
		}
		.tabbox>ul{top: 56px;}
	}
	@media (min-width: 1200px){ 
		/* //>=1200的设备  */
	}

</style>
</head>
<body>
<?php include 'menu.php'; ?>
<header>
	<div class="hd-title">签到统计</div>
	<a class="back" href="javascript:;" onclick="history.go(-1)"><i class="iconfont icon-left-circle"></i></a>
</header>
<div class="page-wrap">

<?php 
if(isset($_SESSION['pwd']) && $_SESSION['pwd'] == $password){ 
###判断该文件是否存在
if(file_exists($file_qd_ok)){
	$file_arr_ok = file($file_qd_ok); ###得到数组
	$file_time = file($file_qd_time); ###得到时间数组
	$files_arr_all = file($file_qd_all); ###得到数组
	// array_shift($files_arr_all); //去掉第一行
	// print_r($file_arr);
	// print_r($files_arr_all);
	// $result = array_unique($file_arr_ok); //去除重复的项

	$arr_notdao = array_diff($files_arr_all,$file_arr_ok);
	$arr_notdao = array_values($arr_notdao);
	$total_ok = count($file_arr_ok);
	$total_not = count($arr_notdao);
	
	    /*echo '<div class="tabbox">
			    <ul>
			    	<li class="active">已签到('.$total_ok.')</li>
			    	<li>未签到('.$total_not.')</li>
			    </ul>
			    <div class="list-content">
				    <div class="item-list active">
	    
	    ';*/
		####对数组的处理
		echo "<div class='myweb2 hidden'>\r\n";
		for ($i=0; $i < $total_ok ; $i++) { 
			# code...
			echo "<div class='item item_ok'>\r\n";
			$tabvs = explode("\t", $file_arr_ok[$i]);
			$tabvs_total = count($tabvs);
			for ($j=0; $j <$tabvs_total ; $j++) { 
				$a = trim($tabvs[$j]);
				echo "<span>".$a."</span>";
				# code...
			}
			echo "<span class='c_time'>".$file_time[$i]."</span>\r\n";
			echo "</div>\r\n";
		}
		echo "</div>\r\n";
		/*
		echo "</div>\r\n";

		echo '<div class="item-list">
		
		';*/
		
		echo "<div class='myweb hidden'>\r\n";
		for ($i=0; $i < $total_not ; $i++) { 
			echo "<div class='item item_a'>\r\n";
			$tabvsb = explode("\t", $arr_notdao[$i]);
			$tabvsb_total = count($tabvsb);
			for ($j=0; $j <$tabvsb_total ; $j++) { 
				$b = trim($tabvsb[$j]);
				echo "<span>".$b."</span>";
				# code...
			}
			echo "</div>\r\n";
			# code...
			// echo "<div class='item'>{$arr_notdao[$i]} </div>\r\n";
		}
		echo "</div>\r\n";

		/*echo "</div>\r\n";
		echo "</div>\r\n";
		echo "</div>\r\n";*/

	// print_r($arr_new);
	#####接下来就是对数组数据的取出#####
?>
<div class="tabbox">
	<ul>
		<li class="active">已签到(<?php echo $total_ok;?>)</li>
		<li>未签到(<?php echo $total_not; ?>)</li>
	</ul>
	<div class="list-content">
		<div class="item-list item-list-ok active">数据加载中，请稍后...</div>
		<div class="more-btn more-ok"><a href="javascript:;" >加载更多</a></div>
		<div class="item-list item-list-not">数据加载中，请稍后...
		</div>
		<div class="more-btn more-not"><a href="javascript:;" >加载更多</a></div>
	</div>
	
</div>
<?php }else{	
	echo "file not exists!";
}
 }else { ?>

 <form id="myform" class="myform" name="form" method="post" action="">
     
     <input class="form-control" name="pwd" type="password" id="pwd" placeholder="请输入密码">
     <input class="btn btn-primary btn-block" type="submit" name="submit5" value="确定">
 </form>

 <?php } 

 ?>
 </div>
<script src="http://lib.baomitu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="inc/js/mobile-menu.js?v=<?php echo $tts;?>"></script>
<script src="inc/js/jquery.more.js?v=<?php echo $tts;?>"></script>
<script type="text/javascript">
$(function(){
	$(".tabbox>ul>li").click(function (){
		//获取点击的元素给其添加样式，讲其兄弟元素的样式移除
		$(this).addClass("active").siblings().removeClass("active");
		//获取选中元素的下标
		var index = $(this).index();
		$(this).parent().siblings(".list-content").children('.item-list').eq(index).addClass("active")
		.siblings().removeClass("active");
	});
	lanren.init(".item_ok", ".item-list-ok", ".myweb2.hidden", _contentb,".more-ok");
	lanren.init(".item_a", ".item-list-not", ".myweb.hidden", _content, ".more-not");
	$('.more-ok').click(function(){
		lanren.loadMore(".item-list-ok .item",".item-list-ok",".more-ok",_contentb);
	});
	$('.more-not').click(function(){
		lanren.loadMore(".item-list-not .item",".item-list-not",".more-not",_content);
	})

});

</script>
</body>
</html>